package com.yunxi.service.dubboService.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.yunxi.model.order.OrderCustomerDetail;
import com.yunxi.order.pojo.OrderCustomerDetailVO;
import com.yunxi.order.service.OrderCustomerDetailDubboService;
import com.yunxi.service.localService.OrderCustomerDetailService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 * 零售订单明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-29
 */
//@com.alibaba.dubbo.config.annotation.Service(version = "${demo.service.version}",
//        application = "${dubbo.application.id}",
//        protocol = "${dubbo.protocol.id}",
//        registry = "${dubbo.registry.id}"
//)
public class OrderCustomerDetailDubboServiceImpl implements OrderCustomerDetailDubboService {

    @Autowired
    @Qualifier(value = "orderCustomerDetailServiceImpl")
    OrderCustomerDetailService orderCustomerDetailService;


    @Override
    public OrderCustomerDetailVO getById(String id) throws InvocationTargetException, IllegalAccessException {
    OrderCustomerDetail orderCustomerDetail = orderCustomerDetailService.getById(id);
    OrderCustomerDetailVO orderCustomerDetailVO = new OrderCustomerDetailVO();
        BeanUtils.copyProperties(orderCustomerDetail,orderCustomerDetailVO);
        return orderCustomerDetailVO;
    }

    @Override
    public void saveOrUpdate(OrderCustomerDetailVO orderCustomerDetailVO) throws InvocationTargetException, IllegalAccessException {
    OrderCustomerDetail orderCustomerDetail = new OrderCustomerDetail();
        BeanUtils.copyProperties(orderCustomerDetailVO,orderCustomerDetail);
    orderCustomerDetailService.saveOrUpdate(orderCustomerDetail);
    }

    @Override
    public void removeById(String id) {
    orderCustomerDetailService.removeById(id);
    }

    @Override
    public PageInfo<OrderCustomerDetailVO> findPageByVO(OrderCustomerDetailVO orderCustomerDetailVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {
      PageInfo<OrderCustomerDetailVO> pageInfo = orderCustomerDetailService.pageByVo(orderCustomerDetailVO,pageNum,pageSize);
      return pageInfo;
   }

    @Override
    public void removeByListVo(List<OrderCustomerDetailVO> orderCustomerDetailVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
        orderCustomerDetailService.removeByListVo(orderCustomerDetailVOList);
    }

   @Override
   public void save(OrderCustomerDetailVO orderCustomerDetailVO) {
      OrderCustomerDetail orderCustomerDetail = new OrderCustomerDetail();
      BeanUtils.copyProperties(orderCustomerDetailVO,orderCustomerDetail);
      orderCustomerDetailService.save(orderCustomerDetail);
   }

   @Override
   public void update(OrderCustomerDetailVO orderCustomerDetailVO ) {
      OrderCustomerDetail orderCustomerDetail = new OrderCustomerDetail();
      BeanUtils.copyProperties(orderCustomerDetailVO,orderCustomerDetail);
      QueryWrapper<OrderCustomerDetail> queryWrapper = new QueryWrapper<>();
      queryWrapper.eq("ORDER_NO",orderCustomerDetailVO.getOrderNo());
      orderCustomerDetailService.update(orderCustomerDetail,queryWrapper);
   }

    @Override
    public OrderCustomerDetailVO getByOrderNo(String orderNo) {
        return orderCustomerDetailService.getOrderNo(orderNo);
    }
}
